package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.dto.StepInfoResponse;
import com.tencent.wxcloudrun.service.WechatService;
import com.tencent.wxcloudrun.util.WxDecryptUtil;
import org.springframework.stereotype.Service;

@Service
public class WechatServiceImpl implements WechatService {

    @Override
    public StepInfoResponse decryptStepInfo(String encryptedData, String iv, String sessionKey) {
        // 调用解密工具类
        String decryptData = WxDecryptUtil.decryptData(
            encryptedData,
            sessionKey,
            iv
        );
        
        // 解析JSON数据
        return parseStepInfo(decryptData);
    }

    private StepInfoResponse parseStepInfo(String jsonData) {
        // 示例解析逻辑，实际需要根据微信返回格式处理
        StepInfoResponse response = new StepInfoResponse();
        response.setStep(10000); // 从JSON中提取真实步数
        response.setRecordDate("2023-07-20"); // 提取日期
        return response;
    }
} 